package com.iwhalecloud.bss.kite.cucc.spec.impl.transfer;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.iwhalecloud.bss.kite.client.dto.spec.ObjAttrRstrRulDTO;
import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.constant.SwitchConsts;
import com.iwhalecloud.bss.kite.common.constant.SymbolConsts;
import com.iwhalecloud.bss.kite.common.util.KiteListUtils;
import com.iwhalecloud.bss.kite.common.util.KiteMapUtils;
import com.iwhalecloud.bss.kite.common.util.KiteObjectUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.common.util.SeqUtils;
import com.iwhalecloud.bss.kite.cucc.dataservice.cache.CuccProdAttrExtCache;
import com.iwhalecloud.bss.kite.cucc.dataservice.cache.ProdRelOfferCache;
import com.iwhalecloud.bss.kite.cucc.dataservice.mapper.spec.CuccOfferAttrMapper;
import com.iwhalecloud.bss.kite.dataservice.cache.*;
import com.iwhalecloud.bss.kite.dataservice.entity.AttrValue;
import com.iwhalecloud.bss.kite.dataservice.entity.DcPublic;
import com.iwhalecloud.bss.kite.dataservice.entity.OfferAttr;
import com.iwhalecloud.bss.kite.dataservice.entity.spec.ProdAttr;
import com.iwhalecloud.bss.kite.dataservice.entity.spec.Product;
import com.iwhalecloud.bss.kite.dataservice.util.GeneralSwitchUtils;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttrValue;
import com.ztesoft.bss.base.staticdata.CoreDataProduct;
import com.ztesoft.bss.base.staticdata.CoreDataPublic;
import com.ztesoft.bss.common.util.ContextUtil;
import com.ztesoft.bss.common.util.SpringUtil;
import com.ztesoft.bss.common.util.StringUtil;

import java.util.*;
import java.util.stream.Collectors;

public class ProductsInfoTransfer {

    private static final String PRODUCT_TYPE_PAY = "pay";

    @SuppressWarnings("unchecked")
    public static Product convertProduct(Map<String, Object> productMap, String cateId, String offerId) {
        if (KiteMapUtils.isNotEmpty(productMap)) {
            Product product = KiteMapUtils.mapToBean(transferField(productMap, coverFieldName()), Product.class);
            if (PRODUCT_TYPE_PAY.equals(productMap.get("productType"))) {
                //资费产品
                product.setBillProdType(CoreDataProduct.PRD_C_0001_5000);
            }
            else {
                //基础产品
                product.setBillProdType(CoreDataProduct.PRD_C_0001_1000);
            }
            product.setStatusCd(CoreDataPublic.PUB_C_0001_1000);
            product.setBaseOfferId(KiteMapUtils.getString(productMap, "baseOfferId"));
            product.setCateId(cateId);
            if(Objects.nonNull(productMap.get("category"))) {
                Map<String,String> category = (Map<String, String>) productMap.get("category");
                product.setProdCatType(category.get("categoryId"));
            }

            product.setProdFuncType(KeyConsts.PROD_FUNC_TYPE_101);
            String isUseSwitch = DcSystemParamCache.getDcParamVal("useLocalProdAttr");
            if(KiteStringUtils.isEqual("F",isUseSwitch)){
                List<Map<String, Object>> prodAttrs = (List<Map<String, Object>>) productMap.get("productAttrs");
                convertProdAttr(prodAttrs, product.getProdId(), cateId);
            }
            // 这里不用放缓存，ProductCache的getObject先从表里查，查不到才通过com.iwhalecloud.bss.kite.cucc.spec.impl.query.ProductQueryService.getProductFromInf调接口查，
            // 父类com.iwhalecloud.bss.kite.common.cache.AbstractCache.prefixGetObject调用完getObject会把查到的结果放入缓存
            // 如果有问题请把这里重新打开
            ProductCache.getInst().defaultPut(product.getProdId(), product);
            ProdRelOfferCache.getInst().defaultPut(product.getProdId(), offerId);
            return product;
        }
        return new Product();
    }

    /**
     * 判断附加产品
     * 统一使用GoodsInfoTransfer.isAddRoleOffer
     * @param cateId
     * @return
     */
    @Deprecated
    public static boolean isAddRoleProduct(String cateId) {
        DcPublic dcPublic = DcPublicCache.get("20201112001", cateId);
        return Objects.nonNull(dcPublic);
    }

    public static List<ProdAttr> convertProdAttr(List<Map<String, Object>> prodAttrs, String prodId, String cateId) {
        if (KiteListUtils.isNotEmpty(prodAttrs)) {
            List<ProdAttr> prodAttrList = new ArrayList<>();
            prodAttrs.stream().forEach(prodAttr -> {
                GoodsInfoTransfer.convertFieldValue(prodAttr);
                GoodsInfoTransfer.convertField(prodAttr, getOfferConvertField());
                ProdAttr attr = KiteMapUtils.mapToBean(prodAttr, ProdAttr.class);
                attr.setProductId(prodId);
                //这里返回的下拉值是约束出来的 每个商品可能不一样 因此给一个唯一的key
                attr.setAttrId(SeqUtils.getNext("SEQ_ATTR_ID"));
                prodAttrList.add(attr);

                cacheProdAttrValue(attr, prodAttr);
            });
            addLanIdAttr(prodAttrList);
            addCateIdAttr(prodAttrList, cateId);
            //产品属性二次配置信息设置
            saveProdAttrCache(prodAttrList, prodId, cateId);
            return prodAttrList;
        }
        return null;
    }

    public static void saveProdAttrCache(List<ProdAttr> prodAttrList, String prodId, String cateId) {
        setProdAttrSpecConfig(prodAttrList, prodId, cateId);
        customizationProdAttr(prodAttrList, prodId);
        ProdAttrCache.getInst().defaultPut(prodId, prodAttrList);
    }

    /**
     * 设置属性二次配置信息，产商品属性配置不完全满足需求的情况下，需要进行产品属性的二次配置
     * @param prodAttrList
     * @param prodId
     * @param cateId
     */
    private static void setProdAttrSpecConfig(List<ProdAttr> prodAttrList, String prodId, String cateId) {
        //添加处理类,根据filename固定的编码来处理
        for (ProdAttr attr : prodAttrList) {
            // 初始化oderId，便于排序
            if (KiteStringUtils.isEmpty(attr.getOrderId())) {
                attr.setOrderId("999");
            }
            List<ProdAttr> prodAttrs = CuccProdAttrExtCache.get(attr.getFieldName(), prodId, cateId);
            if (KiteListUtils.isNotEmpty(prodAttrs)) {
                ProdAttr prodAttrsConfig = prodAttrs.get(0);
                if (StringUtil.isNotEmpty(prodAttrsConfig.getShowType())) {
                    attr.setShowType(prodAttrsConfig.getShowType());
                }
                if (KiteStringUtils.isNotEmpty(prodAttrsConfig.getIsEdit())) {
                    attr.setIsEdit(prodAttrsConfig.getIsEdit());
                }
                if (KiteStringUtils.isNotEmpty(prodAttrsConfig.getAttrValueTypeId())) {
                    attr.setAttrValueTypeId(prodAttrsConfig.getAttrValueTypeId());
                }
                if (KiteStringUtils.isNotEmpty(prodAttrsConfig.getPageUrl())) {
                    attr.setPageUrl(prodAttrsConfig.getPageUrl());
                }
                if (KiteStringUtils.isNotEmpty(prodAttrsConfig.getIsNull())) {
                    attr.setIsNull(prodAttrsConfig.getIsNull());
                }
                if (KiteStringUtils.isNotEmpty(prodAttrsConfig.getOrderId())) {
                    attr.setOrderId(prodAttrsConfig.getOrderId());
                }
                if (KiteStringUtils.isNotEmpty(prodAttrsConfig.getColspan())) {
                    attr.setColspan(prodAttrsConfig.getColspan());
                }
                attr.setHandlerClass(Optional.ofNullable(prodAttrsConfig.getHandlerClass())
                    .orElse("com.iwhalecloud.bss.kite.service.attr.handler.DefaultAttrHandler"));
            }
        }
    }

    /**
     * 设置属性二次配置信息，产商品属性配置不完全满足需求的情况下，需要进行产品属性的二次配置
     * @param prodAttrList
     * @param prodId
     * @param cateId
     */
    private static void customizationProdAttr(List<ProdAttr> prodAttrList, String prodId) {
        List<ProdAttr> prodAttrs = CuccProdAttrExtCache.getProdObject(prodId);
        if (KiteListUtils.isNotEmpty(prodAttrs)) {
            prodAttrs.forEach(prodAttr ->{

                if (KiteStringUtils.isEqual(prodAttr.getAllowCustomizedFlag(), KeyConsts.IFTRUE_T)) {
                    ProdAttr oldProdAttr = prodAttrList.stream().filter(attr -> KiteStringUtils.isEqual(attr.getFieldName(), prodAttr.getFieldName())).findFirst().orElse(null);
                    if (Objects.isNull(oldProdAttr)) {
                        prodAttr.setProductId(prodId);
                        //这里返回的下拉值是约束出来的 每个商品可能不一样 因此给一个唯一的key
                        prodAttr.setAttrId(SeqUtils.getNext("SEQ_ATTR_ID"));
                        prodAttr.setHandlerClass(Optional.ofNullable(prodAttr.getHandlerClass())
                            .orElse("com.iwhalecloud.bss.kite.service.attr.handler.DefaultAttrHandler"));
                        prodAttrList.add(prodAttr);
                    }
                }

            });
        }
    }

    private static void addCateIdAttr(List<ProdAttr> prodAttrList, String cateId) {
        ProdAttr attr = new ProdAttr();
        attr.setProductId(prodAttrList.get(0).getProductId());
        attr.setFieldName("cate_id");
        attr.setAttrId("1010002");
        attr.setCname("产品分类");
        attr.setAttrValueTypeId("98C");
        attr.setStatusCd("1000");
        attr.setIsNull("F");
        attr.setIsEdit("F");
        attr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_E);
        attr.setDefaultValue(cateId);
        attr.setIfDefaultValue("T");
        attr.setHandlerClass("com.iwhalecloud.bss.kite.service.attr.handler.DefaultAttrHandler");
        prodAttrList.add(attr);
    }

    private static void addLanIdAttr(List<ProdAttr> prodAttrList) {
        ProdAttr attr = new ProdAttr();
        attr.setProductId(prodAttrList.get(0).getProductId());
        attr.setFieldName("lan_id");
        attr.setAttrId("1010001");
        attr.setCname("本地网");
        attr.setAttrValueTypeId("98C");
        attr.setStatusCd("1000");
        attr.setIsNull("F");
        attr.setIsEdit("F");
        attr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_E);
        attr.setHandlerClass("com.iwhalecloud.bss.kite.cucc.service.attr.handler.LanIdAttrHandler");
        prodAttrList.add(attr);

    }

    //处理资费产品转可选包属性
    public static void convertPayProdAttr(List<Map<String, Object>> offerAttrs, String offerId, String cateId, String parentOffId) {
        CuccOfferAttrMapper cuccOfferAttrMap = SpringUtil.getBean(CuccOfferAttrMapper.class);
        List<OfferAttr> offerAttrsList = cuccOfferAttrMap.listOfferAttrs(offerId);
        String param_name=DcPublicCache.getCoded("20210602110701",offerId);//控制某个产品不展示某个资费字段
        if (KiteListUtils.isNotEmpty(offerAttrs) && KiteListUtils.isEmpty(offerAttrsList)) {
            offerAttrs.stream().forEach(offerAttr -> {

                GoodsInfoTransfer.convertFieldValue(offerAttr);
                GoodsInfoTransfer.convertField(offerAttr, getOfferConvertField());
                OfferAttr attr = KiteMapUtils.mapToBean(offerAttr, OfferAttr.class);
                if(KiteStringUtils.equals(attr.getFieldName(),param_name)){
                    return;
                }
                attr.setOfferId(offerId);

                //这里返回的下拉值是约束出来的 每个可选包可能不一样 因此给一个唯一的key
                attr.setAttrId(SeqUtils.getNext("SEQ_ATTR_ID"));
                // 资费产品支持按照offerID进行配置属性
                OfferAttr offerAttrDB = cuccOfferAttrMap.getOfferAttrByIdAndFieldName(offerId, attr.getFieldName());
                if (Objects.isNull(offerAttrDB) || KiteStringUtils.equals(offerAttrDB.getOfferId(), "-1")) {
                    offerAttrDB = cuccOfferAttrMap.getOfferAttrByIdAndFieldName(cateId, attr.getFieldName());
                }

                if (Objects.nonNull(offerAttrDB)) {
                    attr.setAttrValueTypeId(offerAttrDB.getAttrValueTypeId());

                    if (!KiteObjectUtils.isEmpty(offerAttrDB.getHandlerClass())) {
                        attr.setHandlerClass(offerAttrDB.getHandlerClass());
                    }
                    if (!KiteObjectUtils.isEmpty(offerAttrDB.getDefaultValue())) {
                        attr.setDefaultValue(offerAttrDB.getDefaultValue());
                    }
                    if (!KiteObjectUtils.isEmpty(offerAttrDB.getIsEdit())) {
                        attr.setIsEdit(offerAttrDB.getIsEdit());
                    }
                    if (!KiteObjectUtils.isEmpty(offerAttrDB.getIsNull())) {
                        attr.setIsNull(offerAttrDB.getIsNull());
                    }
                    if (!KiteObjectUtils.isEmpty(offerAttrDB.getShowType())) {
                        attr.setShowType(offerAttrDB.getShowType());
                    }
                    if (!KiteObjectUtils.isEmpty(offerAttrDB.getAttrFormat())) {
                        attr.setAttrFormat(offerAttrDB.getAttrFormat());
                    }
                    if (!KiteObjectUtils.isEmpty(offerAttrDB.getCheckMessage())) {
                        attr.setCheckMessage(offerAttrDB.getCheckMessage());
                    }
                    if (!KiteObjectUtils.isEmpty(offerAttrDB.getOrderId())) {
                        attr.setOrderId(offerAttrDB.getOrderId());
                    }
                    if (isLinkageAttr(offerId, attr)) {
                        attr.setLinkageFlag(true);
                    }
                }
                offerAttrsList.add(attr);
                cacheOfferAttrValue(attr, offerAttr);
            });
        }
        else {
         // 设置联动的放属性，拿出来单独设置，以免数据库中配置了之后，无法正确
            offerAttrsList.stream().forEach(attr ->{
                if (isLinkageAttr(offerId, attr)) {
                    attr.setLinkageFlag(true);
                }
            });
        }
        
        addRuleResultAttr(offerAttrsList);
        String offerIdd = offerId;
        if (GeneralSwitchUtils.isSwitchOpened(SwitchConsts.OFFER_PROVINCE_SCOPE)) {
            offerIdd = KiteStringUtils.concatWithNnderline(offerIdd, ContextUtil.getLoginInfo().getUserInfo().getPostProvinceNbr());
        }
        //OfferAttrCache.getInst().defaultPut(offerIdd, offerAttrsList);
        offerIdd = KiteStringUtils.concatWithNnderline(parentOffId, offerIdd);
        ProdFeeAttrCache.getInst().defaultPut(offerIdd, offerAttrsList);
    }
    private static void addRuleResultAttr(List<OfferAttr> offerAttrsList) {
        if (KiteListUtils.isEmpty(offerAttrsList)) {
            return;
        }
        List<OfferAttr> list = offerAttrsList.stream().filter(attr -> KiteStringUtils.isEqual(attr.getFieldName(), "rule_result")).collect(Collectors.toList());
        if (KiteListUtils.isEmpty(list)) {
            OfferAttr firstAttr = offerAttrsList.get(0);
//          OfferAttr attr = KiteBeanUtils.transform(offerAttrsList.get(0), OfferAttr.class);
          OfferAttr attr = new OfferAttr();
          attr.setFieldName("rule_result");
          attr.setAttrId("10" + firstAttr.getOfferId());
          attr.setOfferId(firstAttr.getOfferId());
          attr.setOrderId(String.valueOf(offerAttrsList.size()));
          attr.setCname("规则校验结果");
          attr.setAttrValueTypeId("98C");
          attr.setStatusCd("1000");
          attr.setIsNull("F");
          attr.setIsEdit("F");
          attr.setDefaultValue("0:校验通过");
          attr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_E);
          attr.setHandlerClass("com.iwhalecloud.bss.kite.service.attr.handler.DefaultAttrHandler");
          offerAttrsList.add(attr);
        }
    }
    /**
     * FIXME 这里有个问题 如果直接放进去 后面清了的话就找不回来了
     * @param prodAttr
     * @param attr
     */
    @SuppressWarnings("unchecked")
    private static void cacheProdAttrValue(ProdAttr prodAttr, Map<String, Object> attr) {
        if (KeyConsts.DROPDOWN.equals(prodAttr.getAttrValueTypeId()) && KiteStringUtils.isNotBlank(prodAttr.getAttrId())) {
            List<Map<String, Object>> attrValues = (List<Map<String, Object>>) KiteMapUtils.getObject(attr, "attrValues");
            List<AttrValue> attrValueList = null;
            if (KiteListUtils.isNotEmpty(attrValues)) {
                attrValueList = new ArrayList<>();
                int sortId = 1;
                for (Map<String, Object> map : attrValues) {
                    AttrValue attrValue = new AttrValue();
                    attrValue.setAttrValue(KiteMapUtils.getString(map, "valueCode"));
                    attrValue.setAttrValueDesc(KiteMapUtils.getString(map, "valueName"));
                    attrValue.setAttrValueName(attrValue.getAttrValueDesc());
                    attrValue.setAttrValueSort(KiteStringUtils.valueOf(sortId));
                    attrValueList.add(attrValue);

                    sortId++;
                }
            }
            AttrValueCache.getInst().defaultPut(prodAttr.getAttrId(), Optional.ofNullable(attrValueList));
        }
    }


    @SuppressWarnings("unchecked")
    private static void cacheOfferAttrValue(OfferAttr offerAttr, Map<String, Object> attr) {
        if (KeyConsts.DROPDOWN.equals(offerAttr.getAttrValueTypeId()) && KiteStringUtils.isNotBlank(offerAttr.getAttrId())) {
            List<Map<String, Object>> attrValues = (List<Map<String, Object>>) KiteMapUtils.getObject(attr, "attrValues");
            List<AttrValue> attrValueList = null;
            if (KiteListUtils.isNotEmpty(attrValues)) {
                attrValueList = new ArrayList<>();
                int sortId = 1;
                for (Map<String, Object> map : attrValues) {
                    AttrValue attrValue = new AttrValue();
                    attrValue.setAttrValue(KiteMapUtils.getString(map, "valueCode"));
                    attrValue.setAttrValueDesc(KiteMapUtils.getString(map, "valueName"));
                    attrValue.setAttrValueName(attrValue.getAttrValueDesc());
                    attrValue.setAttrValueSort(KiteStringUtils.valueOf(sortId));
                    attrValueList.add(attrValue);
                    sortId++;
                }
            }
            AttrValueCache.getInst().defaultPut(offerAttr.getAttrId(), Optional.ofNullable(attrValueList));
        }
    }

    /**
     * key转换
     * @return
     */
    private static Multimap<String, String> getOfferConvertField() {
        Multimap<String, String> fieldMap = ArrayListMultimap.create();

        fieldMap.put("defaultAttrValCodes", "defaultValue");
        fieldMap.put("valueType", "attrValueTypeId");
        fieldMap.put("keyAttr", "showType");
        fieldMap.put("attrCode", "attrId");
        fieldMap.put("attrName", "cname");
        fieldMap.put("attrCode", "fieldName");


        return fieldMap;
    }


    public static Map<String, Object> transferField(Map<String, Object> data, Map<String, Object> coverMap) {
        coverMap.keySet().forEach(key -> {
            if (data.containsKey(key)) {
                data.put(coverMap.get(key).toString(), data.get(key));
                data.remove(key);
            }
        });
        return data;
    }

    public static Map<String, Object> coverFieldName() {
        Map<String, Object> fieldMap = new HashMap<String, Object>();
        fieldMap.put("productName", "prodName");
        fieldMap.put("productCode", "prodId");
        fieldMap.put("status", "statusCd");
        fieldMap.put("multiRentType", "createType");
        fieldMap.put("prodNbr", "categoryCode");

        return fieldMap;
    }

    private static boolean isLinkageAttr(String offerId, OfferAttr attr) {
        if (!KiteStringUtils.isBlank(attr.getHandlerClass()) && !KiteStringUtils
            .equals(attr.getHandlerClass(), "com.iwhalecloud.bss.kite.service.attr.handler.DefaultAttrHandler")) {
            return true;
        }
        List<ObjAttrRstrRulDTO> ruleDtos = OfferAttrRstrRulCache
            .get(offerId, attr.getFieldName(), true);
        return KiteListUtils.isNotEmpty(ruleDtos);
    }

    /**
     * 将历史枚举存放在ProdHisAttrCache缓存
     * @param productHis
     */
    public static List<KiteAttr> convertHisProdAttr(Map productHis){
        List<KiteAttr> kiteAttrs = new ArrayList<>();
        if(KiteMapUtils.isNotEmpty(productHis)){
            if(KiteMapUtils.isNotEmpty(productHis)&&productHis.containsKey("productAttrs")){
                List<Map> productAttrs = (List<Map>) productHis.get("productAttrs");
                if(KiteListUtils.isNotEmpty(productAttrs)){
                    for (Map prodAttr : productAttrs){
                        if(KiteMapUtils.isNotEmpty(prodAttr)){
                            kiteAttrs.add(transferHisToAttr(prodAttr));
                        }
                    }
                }
            }
        }
        return kiteAttrs;
    }
    private static KiteAttr transferHisToAttr(Map prodAttrMap){
        if(KiteMapUtils.isEmpty(prodAttrMap)){
            return null;
        }
        KiteAttr kiteAttr = new KiteAttr();
        kiteAttr.setFieldName(KiteMapUtils.getString(prodAttrMap,"attrCode"));
        kiteAttr.setCname(KiteMapUtils.getString(prodAttrMap,"attrName"));
        kiteAttr.setGroupId(KiteMapUtils.getString(prodAttrMap,"groupId"));
        kiteAttr.setGroupName(KiteMapUtils.getString(prodAttrMap,"group"));
        kiteAttr.setIsEdit("F");
        kiteAttr.setIsNull("T");
        kiteAttr.setAttrValueTypeId("98C");
        if(prodAttrMap.containsKey("attrValues")){
            List<Map> attrValuesMap = (List<Map>) prodAttrMap.get("attrValues");
            if(KiteListUtils.isNotEmpty(attrValuesMap)){
                kiteAttr.setAttrValueTypeId("98A");
                List<KiteAttrValue> attrvalues = new ArrayList<>();
                for (Map attrValue : attrValuesMap){
                    KiteAttrValue kiteAttrValue = new KiteAttrValue();
                    kiteAttrValue.setAttrValue(KiteMapUtils.getString(attrValue,"valueCode"));
                    kiteAttrValue.setAttrValueName(KiteMapUtils.getString(attrValue,"valueName"));
                    kiteAttrValue.setAttrValueDesc(KiteMapUtils.getString(attrValue,"valueName"));
                    attrvalues.add(kiteAttrValue);
                }
                kiteAttr.setAttrValues(attrvalues);
            }
        }
        return kiteAttr;
    }

    /**
     * 历史节点获取数据
     * @param goodsData
     * @param nodeType
     * @param filterType
     * @return
     */
    public static List<Map> getHistoryDataByNode(Map goodsData, String nodeType ,String filterType){
        List<Map> nodeData = null;
        if(KiteMapUtils.isNotEmpty(goodsData)&&goodsData.containsKey("historyData")){
            Map historyData = KiteMapUtils.getMap(goodsData, "historyData");
            if(KiteMapUtils.isNotEmpty(historyData)&&historyData.containsKey(nodeType)){
                nodeData = (List<Map>) historyData.get(nodeType);
                if(KiteListUtils.isNotEmpty(nodeData)&&KiteStringUtils.isNotEmpty(filterType)&&KiteStringUtils.equals("products",nodeType)){
                    nodeData = nodeData.stream().filter(prod->KiteStringUtils.equalsAny(KiteMapUtils.getString(prod,"productType"),filterType.split(SymbolConsts.COMMA))).collect(Collectors.toList());
                }
            }
        }
        return nodeData;
    }
}
